/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model.config;

import model.util.StoreProcedureParam;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Properties;


/**
 *
 * @author QuocThanh
 */
public class StoreProcedureProperties {

    public enum StoreProcedureKey{
        spTimKiemPhieuTheoTen,
        spTimKiemPhieuTheoGia,
        spTimKiemPhieu,
        spHienThiPhieuTheoTheLoai,
        spPhieuLastId,

        spPhieuNhapLastId,
        spThemPhieuNhap,
        spXoaPhieuNhap,
        spSuaPhieuNhap,
        spThemChiTietPhieuNhap,
        spXoaChiTietPhieuNhap,
        spSuaChiTietPhieuNhap
    }
    
        
    public StoreProcedureProperties() {
        
    }
          
       
   public static ArrayList<StoreProcedureParam> StoreProcedureParams(StoreProcedureKey storePropertiesKey,String...giaTriThamSo) throws FileNotFoundException, IOException{
        Properties pro=new Properties();
        FileInputStream fileInputStream =new FileInputStream(ClassLoader.getSystemResource("StoreProcedure.properties").getFile());
        pro.load(fileInputStream);
        String key=pro.getProperty(storePropertiesKey.toString());
        ArrayList<StoreProcedureParam> lst=new ArrayList<StoreProcedureParam>();
        String[] temp=key.split("=>");
        if(temp.length==1){
            StoreProcedureParam store=new StoreProcedureParam(temp[0]);
            store.setValue(giaTriThamSo[0]);
            lst.add(store);
        }else{
             for (int i = 0; i < temp.length; i++) {
               StoreProcedureParam store=new StoreProcedureParam(temp[i]);
               store.setValue(giaTriThamSo[i]);
               lst.add(store);
        }   
        }
        
        return lst;
   }
}
